package ms.unicorn.ui.figures;

import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.PrecisionPoint;
import org.eclipse.draw2d.geometry.PrecisionRectangle;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.gmf.runtime.draw2d.ui.figures.IOvalAnchorableFigure;
import org.eclipse.gmf.runtime.gef.ui.figures.SlidableOvalAnchor;

public class SliableOvalAnchorEx extends SlidableOvalAnchor {

	public SliableOvalAnchorEx() {

	}

	public SliableOvalAnchorEx(IOvalAnchorableFigure f) {
		super(f);

	}

	public SliableOvalAnchorEx(IOvalAnchorableFigure f, PrecisionPoint p) {
		super(f, p);

	}

	public Point getLocation(Point reference) {
		Rectangle ellipseBox = new PrecisionRectangle(((IOvalAnchorableFigure)getOwner()).getOvalBounds());
		Point ownReference = ellipseBox.getCenter();
		
		Point location = getLocation(ownReference, reference);
		if (location == null) {
			location = getLocation(new PrecisionPoint(getBox().getCenter()), reference);
			if (location == null) {
				location = getBox().getCenter();
			}
		}
		
		return location;
	}
}
